package com.roc.web.action.kymer;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class KYmerSearchCondition extends BaseSearchCondition {

	private String minDate;
	private String maxDate;
	private String merchantNo;
	private String range;
	private String mcc;
	
	
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		// TODO Auto-generated method stub
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		
		if (Constance.isNotEmpty(merchantNo)) {
			filedBeanList.add(new WhereHQLFieldBean("e.MERNO", merchantNo.trim(), "=", false));
		}
		if(Constance.isNotEmpty(minDate)&&Constance.isNotEmpty(maxDate)){
         	filedBeanList.add(new WhereHQLFieldBean("e.etsdate",minDate,">=", false));
       	    filedBeanList.add(new WhereHQLFieldBean("e.etsdate",maxDate,"<=", false));
        }
		if(Constance.isNotEmpty(range)){ //商户号
			if(range.trim().equals("1")){
				filedBeanList.add(new WhereHQLFieldBean("E.AMOUNT",1000000.00,">=",false));
				filedBeanList.add(new WhereHQLFieldBean("E.AMOUNT",2000000.00,"<",false));
			}else if(range.trim().equals("2")){
				filedBeanList.add(new WhereHQLFieldBean("E.AMOUNT",2000000.00,">=",false));
				filedBeanList.add(new WhereHQLFieldBean("E.AMOUNT",3000000.00,"<",false));
			}else if(range.trim().equals("3")){
				filedBeanList.add(new WhereHQLFieldBean("E.AMOUNT",3000000.00,">=",false));
				filedBeanList.add(new WhereHQLFieldBean("E.AMOUNT",4000000.00,"<",false));
			}else if(range.trim().equals("4")){
				filedBeanList.add(new WhereHQLFieldBean("E.AMOUNT",4000000.00,">=",false));	
			}
		}
		
		if(Constance.isNotEmpty(mcc)){
			filedBeanList.add(new WhereHQLFieldBean("m.mcc", mcc.trim(), "=", false));
		}
		
		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		// TODO Auto-generated method stub
		return " select count(*) "+
		 " from ESTRNHISLOG e , ESMIDINFO M "+
		 " where m.mid = e.MERNO and e.REVERSAL = 0 and e.RESPCODE = '00' and e.etstrancode='020000' and e.etstime not  between m.eng_name and m.eng_br_name ";
	}

	@Override
	protected String getSearchHQL() {
		// TODO Auto-generated method stub
	//	return "select  E.ACCOUNT,E.ETSTRANCODE,sum(E.AMOUNT),E.MERNO,E.ETSTERMID,E.ETSDATE " +
		//		"from ESTRNHISLOG e,ESMIDINFO M where e.REVERSAL=0 and e.RESPCODE='00' and m.mid=e.MERNO ";
		return "select  e.MERNO merno, m.mer_name mername,e.ACCOUNT account,e.etstermid etstermid,e.amount amount,e.etsdate||e.etstime etstime,m.mer_status merstatus "+
		" from ESTRNHISLOG e , ESMIDINFO M "+
		" where m.mid = e.MERNO and e.REVERSAL = 0 and e.RESPCODE = '00' and e.etstrancode='020000' and e.etstime not  between m.eng_name and m.eng_br_name ";
	}

	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub
		return " order by e.etsdate DESC ";
	}

	public String getMinDate() {
		return minDate;
	}

	public void setMinDate(String minDate) {
		this.minDate = minDate;
	}

	public String getMaxDate() {
		return maxDate;
	}

	public void setMaxDate(String maxDate) {
		this.maxDate = maxDate;
	}

	public String getMerchantNo() {
		return merchantNo;
	}

	public void setMerchantNo(String merchantNo) {
		this.merchantNo = merchantNo;
	}

	public String getRange() {
		return range;
	}

	public void setRange(String range) {
		this.range = range;
	}

	public String getMcc() {
		return mcc;
	}

	public void setMcc(String mcc) {
		this.mcc = mcc;
	}

	

	
}
